﻿using HeyPiPi_Desk.Domain;
using MaterialDesignThemes.Wpf;
using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HeyPiPi_Desk.Base
{
   public  class BaseNotification:NotificationObject
    {
        /// <summary>
        /// 错误信息
        /// </summary>
        protected string error;
        /// <summary>
        /// 调用警告框
        /// </summary>
        /// <param name="content">警告内容</param>
        /// <param name="rootdialog">父容器</param>
        protected  void ShowDialog(string content,string rootdialog="RootDialog")
        {
          
            
            var dialog = new SampleMessageDialog { Message = { Text = content } };
             DialogHost.Show(dialog, rootdialog, new DialogClosingEventHandler((o,e) => { this.error = null; }));
        }

        /// <summary>
        /// 验证是否需要弹窗,返回false表示有问题，否则返回true
        /// </summary>
        /// <param name="rootdialog"></param>
        protected bool ValidateError(string rootdialog="RootDialog")
        {
            if (!string.IsNullOrWhiteSpace(this.error))
            {
                DialogHost.CloseDialogCommand.Execute(null, null);

                this.ShowDialog(this.error);
                return false;
            }
            return true;
           
        }
    }
}
